#include "head.h"

int net_cd(int net_fd, char *path, request_t *request) {
    printf("flag = %d\n", request->flag);
    printf("user_name = %s\n", request->user_name);
    printf("path = %s\n", request->path);
    strcpy(request->args, path);
    printf("args = %s\n", request->args);

    // 发送请求报文
    int send_size = send(net_fd, request, sizeof(request_t), 0);
    printf("args: %s\n", request->args);
    response_t res;
    memset(&res, 0, sizeof(res));
    recv(net_fd, &res, sizeof(res), 0);
    if (res.status == 1) {
        // 异常返回
        printf("args: %s\n", res.args);
        return -1;
    }
    printf("---响应报文---\n");
    printf("status: %d\n", res.status);
    printf("args: %s\n", res.args);
    printf("-------------\n");
    // strcpy(request->path, path);
    strcat(res.args, "/");
    // strcpy(request->path, res.args);
    strcat(request->path, res.args);
    return 0;
}
